package com.idopartx.phonelightning.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.databinding.DataBindingUtil
import com.idopartx.phonelightning.R
import com.idopartx.phonelightning.databinding.ViewMineIconTextBinding

class MineIconTextView @JvmOverloads constructor(
    context: Context, attrs: AttributeSet? = null
) : ConstraintLayout(context, attrs) {


    init {
        val binding = DataBindingUtil.inflate<ViewMineIconTextBinding>(
            LayoutInflater.from(context),
            R.layout.view_mine_icon_text,
            this,
            true
        )

        val typedArray = context.obtainStyledAttributes(attrs, R.styleable.MineIconTextView)
        val image = typedArray.getResourceId(R.styleable.MineIconTextView_icon, 0)
        binding.ivRight.setImageResource(image)
        val text = typedArray.getString(R.styleable.MineIconTextView_text)
        binding.tvText.text = text
        typedArray.recycle()
    }
}